package com.socket.web;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

public class MultiThreadServer {

	public static void main(String[] args) {
		try {
			ServerSocket serverSocket = new ServerSocket(8080);
			// 死循环
			while (true) {
				System.out.println("MultiThreadServer~~~监听~~~");
				// accept方法会阻塞，直到有客户端与之建立连接
				Socket socket = serverSocket.accept();
//				ServerThread serverThread = new ServerThread(socket);
//				serverThread.start();
				SocketManager socketManager = new SocketManager(socket, null);
				socketManager.start();
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
